package com.chance.cc.crawler.development.command.meta.keyword.dcdapp.forum;

import com.chance.cc.crawler.development.command.meta.keyword.CrawlerDomainKeywordCommand;
import com.chance.cc.crawler.meta.core.bean.crawler.CrawlerDomainKeys;
import org.apache.commons.lang3.StringUtils;

import java.io.*;

public class DcdappKeyword {
    private static final String DOMAIN = "dcdapp";
    private static final String SITE = "sgmkw"; //series  adhocKw  sgmkw
    private static final String path = "E:\\chance-crawler-development\\crawler-scripts-command\\src\\main\\java\\com\\chance\\cc\\crawler\\development\\command\\meta\\keyword\\dcdapp\\forum\\dcdapp_simple.txt";

    private static final String HOST = "192.168.1.217";
    private static final int PORT = 9599;

    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(path)), "UTF-8"));
        String lineData = null;
        while ((lineData = bufferedReader.readLine()) != null){
            if(StringUtils.isBlank(lineData)){
                continue;
            }
            System.out.println(lineData);
            CrawlerDomainKeywordCommand crawlerDomainKeywordCommand = new CrawlerDomainKeywordCommand(HOST,PORT);

            CrawlerDomainKeys crawlerDomainKeys = new CrawlerDomainKeys();
            crawlerDomainKeys.setDomain(DOMAIN);
            crawlerDomainKeys.setSite(SITE);
            crawlerDomainKeys.setKeyword(lineData);
            crawlerDomainKeys.setStatus(0);
            crawlerDomainKeywordCommand.addOrUpdateKeys(crawlerDomainKeys);

        }

    }

}
